import Dexie, { type EntityTable } from 'dexie';
import { type DB } from './DBType';
/**
 * 数据库实例
 */
const dataBaseInstance = new Dexie('billDB') as Dexie & {
	// EntityTable 第二位泛型指定第一位泛型中的主键
	date_source : EntityTable<DB.DateSource, 'dateId'>;
	event_record_source : EntityTable<DB.EventRecordSource, 'eventId'>;
};
dataBaseInstance.version(1).stores({
	date_source: '++dateId, date', // primary key "id" (for the runtime!)
	event_record_source: '++eventId, dateId, eventName, amount, changeType, weight'
});

export default dataBaseInstance;